package supershop3.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import supershop3.dao.IAddressDao;
import supershop3.model.Address;

@Controller
@RequestMapping("/address")
public class AddressController {
	
	@Resource
	private IAddressDao addressDao;
	
	//查询登录用户地址
	@RequestMapping("/findAll.do")
	@ResponseBody
	public Map findAll(int uid) {
		List<Address> list = addressDao.findAll(uid);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code",0);
		map.put("count",100);
		map.put("msg","查询成功");
		map.put("data",list);
		return map;
	}
	
	@RequestMapping("/del.do")
	@ResponseBody
	public int del(int id) {
		return addressDao.del(id);
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public int add(Address a) {
		return addressDao.add(a);
	}
}
